/*
 * EmployeeDataEditor.java
 *
 * Created on November 10, 2006, 3:27 PM
 */

package org.foment.gem.beans;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.sql.Connection;
import java.util.logging.Level;
import javax.swing.event.DocumentEvent;
import static org.foment.joliage3.core.internationalization.Internationalization.i18n;
import org.foment.joliage3.core.logging.Logger;
import static org.foment.joliage3.core.logging.Logger.log;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import java.util.Locale;
import javax.swing.JButton;
import javax.swing.JTextField;
import org.foment.gem.Integrator;
import org.foment.joliage3.sql.Database;
import org.foment.joliage3.newt.*;


/**
 *
 * @author  jaksa
 */
public class EmployeeDataEditor extends javax.swing.JPanel implements java.io.Serializable, org.foment.joliage3.sql.Table.TableEditor {
    
    /** Creates new form EmployeeDataEditor */
    public EmployeeDataEditor() {
      initComponents();
      
      // ovo sam morao rucno da dodajem, jer opet baguje!!!, uklanja ga automatski - ne znam zasto!!
      flg2_EmployeeEducationLevel.setTableName("EducationLevel");
      
      flg2_EmployeeWorkingYears.setLimit(0, 100);
      flg2_EmployeeWorkingMonths.setLimit(0, 12);
      flg2_EmployeeWorkingDays.setLimit(0, 30);
      
      flg2_EmployeeGender.getDocument().addDocumentListener(
        new javax.swing.event.DocumentListener() {
          public void changedUpdate(DocumentEvent documentEvent) { updated(documentEvent); }
          public void insertUpdate(DocumentEvent documentEvent)  { updated(documentEvent); }
          public void removeUpdate(DocumentEvent documentEvent)  { updated(documentEvent); }
          public void updated(DocumentEvent documentEvent) {
            if (flg2_EmployeeGender.getText().equals("m"))         radioMale.setSelected(true);
            else if (flg2_EmployeeGender.getText().equals("f"))    radioFemale.setSelected(true);
            //else                                                   radioMale.setSelected(true);
          }
        }
      );
      
      flg2_EmployeeJobStatus.getDocument().addDocumentListener(
        new javax.swing.event.DocumentListener() {
          public void changedUpdate(DocumentEvent documentEvent) { updated(documentEvent); }
          public void insertUpdate(DocumentEvent documentEvent)  { updated(documentEvent); }
          public void removeUpdate(DocumentEvent documentEvent)  { updated(documentEvent); }
          public void updated(DocumentEvent documentEvent) {
            if (flg2_EmployeeJobStatus.getText().equals("z"))         radioEmployed.setSelected(true);
            else if (flg2_EmployeeJobStatus.getText().equals("n"))    radioFired.setSelected(true);
            else if (flg2_EmployeeJobStatus.getText().equals("p"))    radioRetired.setSelected(true);
            //else                                                   radioEmployed.setSelected(true);
          }
        }
      );
      
      for (java.awt.Component component: getComponents()) {
        if (component.getName() == null || !component.getName().startsWith("flg2")) continue;
        if (javax.swing.JTextField.class.isInstance(component)) {
          ((javax.swing.JTextField)component).getDocument().addDocumentListener(
            new javax.swing.event.DocumentListener() {
              public void changedUpdate(DocumentEvent documentEvent) { updated(documentEvent); }
              public void insertUpdate(DocumentEvent documentEvent)  { updated(documentEvent); }
              public void removeUpdate(DocumentEvent documentEvent)  { updated(documentEvent); }
              public void updated(DocumentEvent documentEvent) {
                setDataModified(true);
              }
            }
          );
        } else {
          component.addPropertyChangeListener(
            new java.beans.PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent evt) {
                if (evt.getPropertyName().equals("value"))
                  setDataModified(true);
              }
            }
          );
        }
      }

      try {
        Database.getTable("Employee").setDataEditor(this);
      } catch (SQLException ex) {
        ex.printStackTrace();
        log("Gem", "EmployeeDataEditor.java", Logger.FATAL_ERROR, i18n("Unable to attach editor to the table."), ex);
      }

      // dugmadima sa panela za pauziranje staza, dodajemo akciju. Kad se klikne na njih - unese novi datum
      // ili izbaci, da se ponovo preracuna staz.
     for (Component c : employeeWorkStagnationPanel.getComponents())
     {
         if (JButton.class.isInstance(c))
             ((JButton)c).addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    calculateWorkingYears();
                }
            });
     }
      setDataModified(false);
    }
    
    public boolean isDataModified() {
      return _modified;
    }
    
    public void setDataModified(boolean modified) {
      _modified = modified;
    }
   
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        flg2_EmployeeGenderOptionGroup = new javax.swing.ButtonGroup();
        flg2_EmployeeJobStatusButtonGroup = new javax.swing.ButtonGroup();
        lblID = new javax.swing.JLabel();
        flg2_EmployeeID = new javax.swing.JFormattedTextField();
        flg2_EmployeeGender = new javax.swing.JTextField();
        lblFirstName = new javax.swing.JLabel();
        flg2_EmployeeFirstName = new javax.swing.JTextField();
        lblSurname = new javax.swing.JLabel();
        flg2_EmployeeSurname = new javax.swing.JTextField();
        lblJMBG = new javax.swing.JLabel();
        lblGender = new javax.swing.JLabel();
        radioMale = new javax.swing.JRadioButton();
        radioFemale = new javax.swing.JRadioButton();
        pnlAddresses = new javax.swing.JPanel();
        pnlBirthAddress = new javax.swing.JPanel();
        lblCountryOfBirth = new javax.swing.JLabel();
        lblStateOfBirth = new javax.swing.JLabel();
        lblCityOfBirth = new javax.swing.JLabel();
        lblDistrictOfBirth = new javax.swing.JLabel();
        flg2_EmployeeCountryOfBirth = new javax.swing.JTextField();
        flg2_EmployeeStateOfBirth = new javax.swing.JTextField();
        flg2_EmployeeCityOfBirth = new javax.swing.JTextField();
        flg2_EmployeeDistrictOfBirth = new javax.swing.JTextField();
        pnlAddress = new javax.swing.JPanel();
        lblCountry = new javax.swing.JLabel();
        lblState = new javax.swing.JLabel();
        lblCity = new javax.swing.JLabel();
        lblDistrict = new javax.swing.JLabel();
        lblStreet = new javax.swing.JLabel();
        flg2_EmployeeCountry = new javax.swing.JTextField();
        flg2_EmployeeState = new javax.swing.JTextField();
        flg2_EmployeeCity = new javax.swing.JTextField();
        flg2_EmployeeDistrict = new javax.swing.JTextField();
        flg2_EmployeeStreet = new javax.swing.JTextField();
        flg2_EmployeeJMBG = new javax.swing.JFormattedTextField();
        lblWorkingYears = new javax.swing.JLabel();
        pnlEmployeeDataEditorButtons = new javax.swing.JPanel();
        lblEducationLevel = new javax.swing.JLabel();
        lblDateOfBirth = new javax.swing.JLabel();
        pnlBirthAddress1 = new javax.swing.JPanel();
        lblEmployeeJobStatus = new javax.swing.JLabel();
        radioEmployed = new javax.swing.JRadioButton();
        radioRetired = new javax.swing.JRadioButton();
        radioFired = new javax.swing.JRadioButton();
        lblEmploymentDate = new javax.swing.JLabel();
        flg2_EmployeeJobStatus = new javax.swing.JTextField();
        flg2_EmployeeJobDate = new org.foment.joliage3.newt.DateField();
        checkLimited = new javax.swing.JCheckBox();
        flg2_EmployeeJobExpirationDate = new org.foment.joliage3.newt.DateField();
        employeeWorkStagnationPanel = new org.foment.gem.beans.EmployeeWorkStagnationPanel();
        flg2_EmployeeDateOfBirth = new org.foment.joliage3.newt.DateField();
        flg2_EmployeeWorkingYears = new org.foment.joliage3.newt.IntegerField();
        flg2_EmployeeEducationLevel = new org.foment.joliage3.newt.SQLComboBox();
        btnDelete = new javax.swing.JButton();
        btnUpdate = new javax.swing.JButton();
        btnReset = new javax.swing.JButton();
        btnInsert = new javax.swing.JButton();
        btnInsertNew = new javax.swing.JButton();
        flg2_EmployeeLBO = new javax.swing.JFormattedTextField();
        lblLBO = new javax.swing.JLabel();
        txtCurrentWorkingYears = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        flg2_EmployeeWorkingMonths = new org.foment.joliage3.newt.IntegerField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        txtCurrentWorkingMonths = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        flg2_EmployeeMidName = new javax.swing.JTextField();
        lblParentName = new javax.swing.JLabel();
        flg2_EmployeeWorkingDays = new org.foment.joliage3.newt.IntegerField();
        jLabel6 = new javax.swing.JLabel();
        txtCurrentWorkingDays = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();

        lblID.setText(i18n("ID"));

        flg2_EmployeeID.setEditable(false);
        flg2_EmployeeID.setName("flg2_EmployeeID"); // NOI18N

        flg2_EmployeeGender.setEditable(false);
        flg2_EmployeeGender.setName("flg2_EmployeeGender"); // NOI18N
        flg2_EmployeeGender.setVisible(false);

        lblFirstName.setText(i18n("First Name"));

        flg2_EmployeeFirstName.setName("flg2_EmployeeFirstName"); // NOI18N

        lblSurname.setText(i18n("Surname"));

        flg2_EmployeeSurname.setName("flg2_EmployeeSurname"); // NOI18N

        lblJMBG.setText(i18n("JMBG"));

        lblGender.setText(i18n("Gender"));

        flg2_EmployeeGenderOptionGroup.add(radioMale);
        radioMale.setText(i18n("Male"));
        radioMale.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        radioMale.setMargin(new java.awt.Insets(0, 0, 0, 0));
        radioMale.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                radioMaleItemStateChanged(evt);
            }
        });

        flg2_EmployeeGenderOptionGroup.add(radioFemale);
        radioFemale.setText(i18n("Female"));
        radioFemale.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        radioFemale.setMargin(new java.awt.Insets(0, 0, 0, 0));
        radioFemale.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                radioFemaleItemStateChanged(evt);
            }
        });

        pnlAddresses.setLayout(new java.awt.GridLayout(1, 2, 8, 8));

        pnlBirthAddress.setBorder(javax.swing.BorderFactory.createTitledBorder(flg2_EmployeeJMBG.getBorder(), i18n("Birth place") + ":", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Dialog", 1, 14))); // NOI18N

        lblCountryOfBirth.setText(i18n("Country"));
        lblCountryOfBirth.setMaximumSize(new java.awt.Dimension(100, 15));
        lblCountryOfBirth.setMinimumSize(new java.awt.Dimension(100, 15));

        lblStateOfBirth.setText(i18n("State"));
        lblStateOfBirth.setMaximumSize(new java.awt.Dimension(100, 15));
        lblStateOfBirth.setMinimumSize(new java.awt.Dimension(100, 15));

        lblCityOfBirth.setText(i18n("City"));
        lblCityOfBirth.setMaximumSize(new java.awt.Dimension(100, 15));
        lblCityOfBirth.setMinimumSize(new java.awt.Dimension(100, 15));

        lblDistrictOfBirth.setText(i18n("District"));
        lblDistrictOfBirth.setMaximumSize(new java.awt.Dimension(100, 15));
        lblDistrictOfBirth.setMinimumSize(new java.awt.Dimension(100, 15));

        flg2_EmployeeCountryOfBirth.setName("flg2_EmployeeCountryOfBirth"); // NOI18N

        flg2_EmployeeStateOfBirth.setName("flg2_EmployeeStateOfBirth"); // NOI18N

        flg2_EmployeeCityOfBirth.setName("flg2_EmployeeCityOfBirth"); // NOI18N

        flg2_EmployeeDistrictOfBirth.setName("flg2_EmployeeDistrictOfBirth"); // NOI18N

        org.jdesktop.layout.GroupLayout pnlBirthAddressLayout = new org.jdesktop.layout.GroupLayout(pnlBirthAddress);
        pnlBirthAddress.setLayout(pnlBirthAddressLayout);
        pnlBirthAddressLayout.setHorizontalGroup(
            pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlBirthAddressLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, lblCountryOfBirth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, lblStateOfBirth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, lblCityOfBirth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .add(org.jdesktop.layout.GroupLayout.LEADING, lblDistrictOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(flg2_EmployeeCountryOfBirth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
                    .add(flg2_EmployeeStateOfBirth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
                    .add(flg2_EmployeeCityOfBirth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
                    .add(flg2_EmployeeDistrictOfBirth, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))
                .addContainerGap())
        );
        pnlBirthAddressLayout.setVerticalGroup(
            pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlBirthAddressLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblCountryOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeCountryOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblStateOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeStateOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblCityOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeCityOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlBirthAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblDistrictOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeDistrictOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(51, Short.MAX_VALUE))
        );

        pnlAddresses.add(pnlBirthAddress);

        pnlAddress.setBorder(javax.swing.BorderFactory.createTitledBorder(flg2_EmployeeJMBG.getBorder(), i18n("Residence address") + ":", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Dialog", 1, 14))); // NOI18N

        lblCountry.setText(i18n("Country"));
        lblCountry.setMaximumSize(new java.awt.Dimension(100, 15));
        lblCountry.setMinimumSize(new java.awt.Dimension(100, 15));

        lblState.setText(i18n("State"));
        lblState.setMaximumSize(new java.awt.Dimension(100, 15));
        lblState.setMinimumSize(new java.awt.Dimension(100, 15));

        lblCity.setText(i18n("City"));
        lblCity.setMaximumSize(new java.awt.Dimension(100, 15));
        lblCity.setMinimumSize(new java.awt.Dimension(100, 15));

        lblDistrict.setText(i18n("District"));
        lblDistrict.setMaximumSize(new java.awt.Dimension(100, 15));
        lblDistrict.setMinimumSize(new java.awt.Dimension(100, 15));

        lblStreet.setText(i18n("Address"));
        lblStreet.setMaximumSize(new java.awt.Dimension(100, 15));
        lblStreet.setMinimumSize(new java.awt.Dimension(100, 15));

        flg2_EmployeeCountry.setName("flg2_EmployeeCountry"); // NOI18N

        flg2_EmployeeState.setName("flg2_EmployeeState"); // NOI18N

        flg2_EmployeeCity.setName("flg2_EmployeeCity"); // NOI18N

        flg2_EmployeeDistrict.setName("flg2_EmployeeDistrict"); // NOI18N

        flg2_EmployeeStreet.setName("flg2_EmployeeStreet"); // NOI18N

        org.jdesktop.layout.GroupLayout pnlAddressLayout = new org.jdesktop.layout.GroupLayout(pnlAddress);
        pnlAddress.setLayout(pnlAddressLayout);
        pnlAddressLayout.setHorizontalGroup(
            pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlAddressLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlAddressLayout.createSequentialGroup()
                        .add(lblCountry, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(flg2_EmployeeCountry, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))
                    .add(pnlAddressLayout.createSequentialGroup()
                        .add(lblState, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(flg2_EmployeeState, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))
                    .add(pnlAddressLayout.createSequentialGroup()
                        .add(lblStreet, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(flg2_EmployeeStreet, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))
                    .add(pnlAddressLayout.createSequentialGroup()
                        .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblCity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblDistrict, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(flg2_EmployeeDistrict, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
                            .add(flg2_EmployeeCity, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))))
                .addContainerGap())
        );
        pnlAddressLayout.setVerticalGroup(
            pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlAddressLayout.createSequentialGroup()
                .addContainerGap()
                .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblCountry, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeCountry, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblState, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeState, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 19, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblCity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeCity, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblDistrict, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeDistrict, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlAddressLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblStreet, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeStreet, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(26, Short.MAX_VALUE))
        );

        pnlAddresses.add(pnlAddress);

        flg2_EmployeeJMBG.setFormatterFactory(new javax.swing.JFormattedTextField.AbstractFormatterFactory() {
            public javax.swing.JFormattedTextField.AbstractFormatter getFormatter(javax.swing.JFormattedTextField tf) {
                try {
                    javax.swing.text.MaskFormatter mask = new javax.swing.text.MaskFormatter("#############");
                    //mask.setPlaceholder("0000000000000");
                    mask.setPlaceholderCharacter('0');
                    return mask;
                } catch (java.text.ParseException ex) {
                    ex.printStackTrace();
                }
                return null;
            }
        });
        flg2_EmployeeJMBG.setMinimumSize(new java.awt.Dimension(100, 19));
        flg2_EmployeeJMBG.setName("flg2_EmployeeJMBG"); // NOI18N

        lblWorkingYears.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        lblWorkingYears.setText(i18n("Work years"));

        org.jdesktop.layout.GroupLayout pnlEmployeeDataEditorButtonsLayout = new org.jdesktop.layout.GroupLayout(pnlEmployeeDataEditorButtons);
        pnlEmployeeDataEditorButtons.setLayout(pnlEmployeeDataEditorButtonsLayout);
        pnlEmployeeDataEditorButtonsLayout.setHorizontalGroup(
            pnlEmployeeDataEditorButtonsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 660, Short.MAX_VALUE)
        );
        pnlEmployeeDataEditorButtonsLayout.setVerticalGroup(
            pnlEmployeeDataEditorButtonsLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 25, Short.MAX_VALUE)
        );

        lblEducationLevel.setText(i18n("Education level"));

        lblDateOfBirth.setText(i18n("Date of Birth"));

        pnlBirthAddress1.setBorder(javax.swing.BorderFactory.createTitledBorder(flg2_EmployeeJMBG.getBorder(), i18n("Basic employment information") + ":", javax.swing.border.TitledBorder.LEFT, javax.swing.border.TitledBorder.ABOVE_TOP, new java.awt.Font("Dialog", 1, 14))); // NOI18N

        lblEmployeeJobStatus.setText(i18n("Status"));
        lblEmployeeJobStatus.setMaximumSize(new java.awt.Dimension(100, 15));
        lblEmployeeJobStatus.setMinimumSize(new java.awt.Dimension(100, 15));

        flg2_EmployeeJobStatusButtonGroup.add(radioEmployed);
        radioEmployed.setText(i18n("Employed"));
        radioEmployed.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        radioEmployed.setMargin(new java.awt.Insets(0, 0, 0, 0));
        radioEmployed.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                radioEmployedItemStateChanged(evt);
            }
        });

        flg2_EmployeeJobStatusButtonGroup.add(radioRetired);
        radioRetired.setText(i18n("Retired"));
        radioRetired.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        radioRetired.setMargin(new java.awt.Insets(0, 0, 0, 0));
        radioRetired.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                radioRetiredItemStateChanged(evt);
            }
        });

        flg2_EmployeeJobStatusButtonGroup.add(radioFired);
        radioFired.setText(i18n("Fired"));
        radioFired.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        radioFired.setMargin(new java.awt.Insets(0, 0, 0, 0));
        radioFired.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                radioFiredItemStateChanged(evt);
            }
        });

        lblEmploymentDate.setText(i18n("Employment date"));
        lblEmploymentDate.setMaximumSize(new java.awt.Dimension(100, 15));
        lblEmploymentDate.setMinimumSize(new java.awt.Dimension(100, 15));

        flg2_EmployeeJobStatus.setEditable(false);
        flg2_EmployeeJobStatus.setName("flg2_EmployeeJobStatus"); // NOI18N
        flg2_EmployeeJobStatus.setVisible(false);

        flg2_EmployeeJobDate.setName("flg2_EmployeeJobDate"); // NOI18N

        checkLimited.setText(i18n("Limited"));
        checkLimited.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
        checkLimited.setMargin(new java.awt.Insets(0, 0, 0, 0));
        checkLimited.addItemListener(new java.awt.event.ItemListener() {
            public void itemStateChanged(java.awt.event.ItemEvent evt) {
                checkLimitedItemStateChanged(evt);
            }
        });

        flg2_EmployeeJobExpirationDate.setName("flg2_EmployeeJobExpirationDate"); // NOI18N
        flg2_EmployeeJobExpirationDate.setVisible(false);
        flg2_EmployeeJobExpirationDate.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                flg2_EmployeeJobExpirationDatePropertyChange(evt);
            }
        });

        org.jdesktop.layout.GroupLayout pnlBirthAddress1Layout = new org.jdesktop.layout.GroupLayout(pnlBirthAddress1);
        pnlBirthAddress1.setLayout(pnlBirthAddress1Layout);
        pnlBirthAddress1Layout.setHorizontalGroup(
            pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlBirthAddress1Layout.createSequentialGroup()
                .addContainerGap()
                .add(pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlBirthAddress1Layout.createSequentialGroup()
                        .add(lblEmployeeJobStatus, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(radioEmployed)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(radioRetired)
                        .add(6, 6, 6)
                        .add(radioFired)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(flg2_EmployeeJobStatus, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                    .add(pnlBirthAddress1Layout.createSequentialGroup()
                        .add(pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblEmploymentDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 121, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(checkLimited))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(flg2_EmployeeJobExpirationDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 155, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(flg2_EmployeeJobDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 155, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 55, Short.MAX_VALUE)
                .add(employeeWorkStagnationPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(24, 24, 24))
        );
        pnlBirthAddress1Layout.setVerticalGroup(
            pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(pnlBirthAddress1Layout.createSequentialGroup()
                .add(pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlBirthAddress1Layout.createSequentialGroup()
                        .addContainerGap()
                        .add(pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                            .add(lblEmployeeJobStatus, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(radioEmployed)
                            .add(radioRetired)
                            .add(radioFired)
                            .add(flg2_EmployeeJobStatus, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblEmploymentDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(flg2_EmployeeJobDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(pnlBirthAddress1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(checkLimited)
                            .add(flg2_EmployeeJobExpirationDate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                    .add(employeeWorkStagnationPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        flg2_EmployeeDateOfBirth.setName("flg2_EmployeeDateOfBirth"); // NOI18N

        flg2_EmployeeWorkingYears.setName("flg2_EmployeeWorkingYears"); // NOI18N

        flg2_EmployeeEducationLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "", "", "", "", "", "", "", "", "", "", "" }));
        flg2_EmployeeEducationLevel.setFieldName("EducationLevelTitle");
        flg2_EmployeeEducationLevel.setKeyName("EducationLevelID");
        flg2_EmployeeEducationLevel.setName("flg2_EmployeeEducationLevel"); // NOI18N

        btnDelete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foment/gem/images/employees_button_delete.png"))); // NOI18N
        btnDelete.setText(i18n("Delete"));
        btnDelete.setEnabled(false);
        btnDelete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnDeleteActionPerformed(evt);
            }
        });

        btnUpdate.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foment/gem/images/employees_button_update.png"))); // NOI18N
        btnUpdate.setText(i18n("Update"));
        btnUpdate.setEnabled(false);
        btnUpdate.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnUpdateActionPerformed(evt);
            }
        });

        btnReset.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foment/gem/images/employees_button_reset.png"))); // NOI18N
        btnReset.setText(i18n("Reset"));
        btnReset.setEnabled(false);
        btnReset.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnResetActionPerformed(evt);
            }
        });

        btnInsert.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/foment/gem/images/employees_button_insert.png"))); // NOI18N
        btnInsert.setText(i18n("Save changes"));
        btnInsert.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInsertActionPerformed(evt);
            }
        });

        btnInsertNew.setText(i18n("Insert new employee"));
        btnInsertNew.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnInsertNewActionPerformed(evt);
            }
        });

        flg2_EmployeeLBO.setFormatterFactory(new javax.swing.JFormattedTextField.AbstractFormatterFactory() {
            public javax.swing.JFormattedTextField.AbstractFormatter getFormatter(javax.swing.JFormattedTextField tf) {
                try {
                    javax.swing.text.MaskFormatter mask = new javax.swing.text.MaskFormatter("###########");
                    //mask.setPlaceholder("0000000000000");
                    mask.setPlaceholderCharacter('0');
                    return mask;
                } catch (java.text.ParseException ex) {
                    ex.printStackTrace();
                }
                return null;
            }
        });
        flg2_EmployeeLBO.setMinimumSize(new java.awt.Dimension(100, 19));
        flg2_EmployeeLBO.setName("flg2_EmployeeLBO"); // NOI18N

        lblLBO.setText(i18n("LBO"));

        txtCurrentWorkingYears.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtCurrentWorkingYears.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        txtCurrentWorkingYears.setEnabled(false);

        jLabel1.setText(i18n("Current work years"));

        flg2_EmployeeWorkingMonths.setName("flg2_EmployeeWorkingMonths"); // NOI18N

        jLabel2.setText("god.");

        jLabel3.setText("meseci");

        jLabel4.setText("god.");

        txtCurrentWorkingMonths.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtCurrentWorkingMonths.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        txtCurrentWorkingMonths.setEnabled(false);

        jLabel5.setText("meseci");

        flg2_EmployeeMidName.setName("flg2_EmployeeMidName"); // NOI18N

        lblParentName.setText(i18n("Parent Name"));

        flg2_EmployeeWorkingDays.setName("flg2_EmployeeWorkingDays"); // NOI18N

        jLabel6.setText("dana");

        txtCurrentWorkingDays.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        txtCurrentWorkingDays.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        txtCurrentWorkingDays.setEnabled(false);

        jLabel7.setText("dana");

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(layout.createSequentialGroup()
                                .add(btnInsertNew)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnInsert, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 150, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(pnlEmployeeDataEditorButtons, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(layout.createSequentialGroup()
                                        .add(lblID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeID, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 819, Short.MAX_VALUE))
                                    .add(layout.createSequentialGroup()
                                        .add(lblFirstName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeFirstName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 227, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .add(18, 18, 18)
                                        .add(lblParentName)
                                        .add(10, 10, 10)
                                        .add(flg2_EmployeeMidName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE))
                                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                                        .add(lblSurname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeSurname, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 819, Short.MAX_VALUE)))
                                .add(0, 0, 0))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, pnlAddresses, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 923, Short.MAX_VALUE)
                            .add(layout.createSequentialGroup()
                                .add(btnDelete, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnUpdate, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(btnReset, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 120, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(lblGender, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                    .add(lblLBO, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(flg2_EmployeeLBO, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 819, Short.MAX_VALUE)
                                    .add(layout.createSequentialGroup()
                                        .add(radioMale)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(radioFemale)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeGender, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 52, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
                            .add(layout.createSequentialGroup()
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                        .add(lblJMBG, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeJMBG, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                                    .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
                                        .add(lblDateOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeDateOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 244, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .add(4, 4, 4)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(layout.createSequentialGroup()
                                        .add(14, 14, 14)
                                        .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(txtCurrentWorkingYears))
                                    .add(layout.createSequentialGroup()
                                        .add(lblWorkingYears, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeWorkingYears, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
                                    .add(layout.createSequentialGroup()
                                        .add(jLabel2)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeWorkingMonths, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 65, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(jLabel3)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(flg2_EmployeeWorkingDays, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                                    .add(layout.createSequentialGroup()
                                        .add(jLabel4)
                                        .add(18, 18, 18)
                                        .add(txtCurrentWorkingMonths, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 54, Short.MAX_VALUE)
                                        .add(1, 1, 1)
                                        .add(jLabel5)
                                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                        .add(txtCurrentWorkingDays, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 54, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                                    .add(jLabel6)
                                    .add(jLabel7))
                                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 196, Short.MAX_VALUE))
                            .add(org.jdesktop.layout.GroupLayout.TRAILING, pnlBirthAddress1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addContainerGap())
                    .add(layout.createSequentialGroup()
                        .add(lblEducationLevel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 100, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(flg2_EmployeeEducationLevel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 292, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(pnlEmployeeDataEditorButtons, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                        .add(btnInsertNew)
                        .add(btnInsert)))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblID)
                    .add(flg2_EmployeeID, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblFirstName)
                    .add(flg2_EmployeeFirstName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(flg2_EmployeeMidName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(lblParentName))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblSurname)
                    .add(flg2_EmployeeSurname, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(layout.createSequentialGroup()
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(lblWorkingYears)
                            .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
                                .add(jLabel2)
                                .add(flg2_EmployeeWorkingYears, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(flg2_EmployeeWorkingMonths, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel3)
                                .add(flg2_EmployeeWorkingDays, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                                .add(jLabel6))))
                    .add(layout.createSequentialGroup()
                        .add(6, 6, 6)
                        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                            .add(flg2_EmployeeDateOfBirth, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                            .add(lblDateOfBirth))))
                .add(6, 6, 6)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblJMBG)
                    .add(flg2_EmployeeJMBG, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(txtCurrentWorkingYears, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel4)
                    .add(jLabel5)
                    .add(jLabel1)
                    .add(jLabel7)
                    .add(txtCurrentWorkingDays, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(txtCurrentWorkingMonths, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(flg2_EmployeeLBO, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(lblLBO))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblGender)
                    .add(radioMale)
                    .add(radioFemale)
                    .add(flg2_EmployeeGender, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(lblEducationLevel)
                    .add(flg2_EmployeeEducationLevel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(pnlBirthAddress1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(35, 35, 35)
                .add(pnlAddresses, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 193, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(btnReset)
                    .add(btnUpdate)
                    .add(btnDelete))
                .addContainerGap(50, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

  private boolean checkLimitedReact = true;
  
  private void flg2_EmployeeJobExpirationDatePropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_flg2_EmployeeJobExpirationDatePropertyChange
    if (evt.getPropertyName().equals("value")) {
      if (evt.getNewValue() == null) {
        checkLimitedReact = false;
        checkLimited.setSelected(false);
        flg2_EmployeeJobExpirationDate.setVisible(false);
        checkLimitedReact = true;
      } else {
        checkLimitedReact = false;
        checkLimited.setSelected(true);
        flg2_EmployeeJobExpirationDate.setVisible(true);
        checkLimitedReact = true;
      }
    }
  }//GEN-LAST:event_flg2_EmployeeJobExpirationDatePropertyChange

  private void checkLimitedItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_checkLimitedItemStateChanged
    if (!checkLimitedReact) return ;
    if (evt.getStateChange() == evt.SELECTED) {
      flg2_EmployeeJobExpirationDate.setValue(flg2_EmployeeJobDate.getValue());
      flg2_EmployeeJobExpirationDate.setVisible(true);
    } else {
      flg2_EmployeeJobExpirationDate.setValue(null);
      flg2_EmployeeJobExpirationDate.setVisible(false);
    }
    setDataModified(true);
  }//GEN-LAST:event_checkLimitedItemStateChanged

  private void radioFiredItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_radioFiredItemStateChanged
    if (evt.getStateChange() == evt.SELECTED)
      if (!flg2_EmployeeJobStatus.getText().equals("n")) {
        flg2_EmployeeJobStatus.setText("n");
        setDataModified(true);
      }
  }//GEN-LAST:event_radioFiredItemStateChanged

  private void radioRetiredItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_radioRetiredItemStateChanged
    if (evt.getStateChange() == evt.SELECTED)
      if (!flg2_EmployeeJobStatus.getText().equals("p")) {
        flg2_EmployeeJobStatus.setText("p");
        setDataModified(true);
      }
  }//GEN-LAST:event_radioRetiredItemStateChanged

  private void radioEmployedItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_radioEmployedItemStateChanged
    if (evt.getStateChange() == evt.SELECTED)
      if (!flg2_EmployeeJobStatus.getText().equals("z")) {
        flg2_EmployeeJobStatus.setText("z");
        setDataModified(true);
      }
  }//GEN-LAST:event_radioEmployedItemStateChanged

  private void btnDeleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeleteActionPerformed
    try {
      if (org.foment.joliage3.newt.Question.showQuestion(
        i18n("Deletion"), 
        i18n("This action can not be undoed. It will delete all record related to the selected employee including job positions. Are you sure you want to proceed?"),
        i18n("Yes"), i18n("No")) != org.foment.joliage3.newt.Question.STATUS_YES
      ) return ;

      ResultSet rs = Database.getTable("Employee").getResultSet();
      int id = rs.getInt("EmployeeID");

     
      // ubaciti da se brisu svi podaci za tog zaposlenog - Insurance, Education...
      Database.getTable("Employee").deleteRow();

      Connection  conn = Database.getConnection();
      conn.createStatement().executeUpdate("DELETE FROM EmployeeCourse WHERE employeeID = " + id);
      conn.createStatement().executeUpdate("DELETE FROM EmployeeEducation WHERE employeeID = " + id);
      conn.createStatement().executeUpdate("DELETE FROM EmployeeInsurance WHERE employeeID = " + id);
      conn.createStatement().executeUpdate("DELETE FROM EmployeeJobType WHERE employeeID = " + id);
      conn.createStatement().executeUpdate("DELETE FROM EmployeeReportCache WHERE employeeID = " + id);
      conn.createStatement().executeUpdate("DELETE FROM EmployeeWorkStagnation WHERE employeeID = " + id);
      conn.close();
      
      java.awt.Container parent = getParent();
      
      while (parent != null && !org.foment.gem.dialogs.EmployeesDialog.class.isInstance(parent))
        parent = parent.getParent();
      if (parent != null)      
        ((org.foment.gem.dialogs.EmployeesDialog)parent).setActiveEmployee(-1);

      clearEditor();
      setEditing(false); 
    } catch (SQLException ex) {
      ex.printStackTrace();
    }
  }//GEN-LAST:event_btnDeleteActionPerformed

  private void flg2_EmployeeWorkingYearsPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_flg2_EmployeeWorkingYearsPropertyChange
    if (evt.getPropertyName().equals("value"))
      setDataModified(true);
  }//GEN-LAST:event_flg2_EmployeeWorkingYearsPropertyChange

  private void btnInsertActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInsertActionPerformed
    try
    {
        Connection  conn = Database.getConnection();
      ResultSet rs = conn.createStatement().executeQuery("SELECT max(EmployeeID) + 1 as InsertID FROM Employee");
      
      int InsertID = 0;
      if (rs.first()) {
        InsertID = rs.getInt("InsertID");
      }
      
      rs.close();
      conn.close();
      
      flg2_EmployeeID.setText(String.valueOf(InsertID));
      
      Database.getTable("Employee").insertCurrentRow();
      
      org.foment.gem.Integrator.getIntegrator().setActiveEmployee(InsertID);
      
    } catch (SQLException ex) {
      log("Gem", "integrator.java", Logger.ERROR, i18n("Unable to insert data"), ex);
    }
  }//GEN-LAST:event_btnInsertActionPerformed

  private void btnUpdateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUpdateActionPerformed
    try {
      Database.getTable("Employee").updateCurrentRow();
      //Database.getConnection().createStatement().executeUpdate("");
      setEditing(true); // Forsiramo izracunavanje staza. Moze i elegannije - ako bude vremena. :)
    } catch (SQLException ex) {
      log("Gem", "integrator.java", Logger.ERROR, i18n("Unable to update data"), ex);
    }
  }//GEN-LAST:event_btnUpdateActionPerformed

  private void btnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetActionPerformed
    try {
      Database.getTable("Employee").resetEditorData();
    } catch (SQLException ex) {
      log("Gem", "integrator.java", Logger.ERROR, i18n("Unable to reset row"), ex);
    }
  }//GEN-LAST:event_btnResetActionPerformed

    private void radioFemaleItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_radioFemaleItemStateChanged
      if (evt.getStateChange() == evt.SELECTED)
        if (!flg2_EmployeeGender.getText().equals("f")) {
          flg2_EmployeeGender.setText("f");
          setDataModified(true);
        }
    }//GEN-LAST:event_radioFemaleItemStateChanged

    private void radioMaleItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_radioMaleItemStateChanged
      if (evt.getStateChange() == evt.SELECTED)
        if (!flg2_EmployeeGender.getText().equals("m")) {
          flg2_EmployeeGender.setText("m");
          setDataModified(true);
        }
    }//GEN-LAST:event_radioMaleItemStateChanged

    private void btnInsertNewActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnInsertNewActionPerformed
      /* clears all fields for storing new employee in database

         -- uraditi da izmeni polja i za preostala 3 panela (raditi preko linkedList)


       */

      clearEditor();
      

    }//GEN-LAST:event_btnInsertNewActionPerformed

  public void activateEditor() {
    setDataModified(false);
    setEditing(true);
  }

  /* see if user has all privileges or disable all elements */
  private void checkPrivileges() {

      // if user doesn't have all access disable all fields
      if (!Integrator._user.getPrivAllAccess()) {

          java.util.LinkedList<java.awt.Container> containers = new java.util.LinkedList();
          containers.add(this);
          containers.add(pnlBirthAddress1);
          containers.add(pnlBirthAddress);
          containers.add(pnlAddress);

          while(!containers.isEmpty()) {

             java.awt.Container current = containers.getFirst(); // get first element from list
             containers.removeFirst();                           // now remove it from list, it is not needed anymore

             for (java.awt.Component component: current.getComponents())
                  component.setEnabled(false);
         }

         // now disable buttons

         btnInsert.setEnabled(false);
         
         btnDelete.setEnabled(false);
         btnDelete.setVisible(false);
         btnUpdate.setEnabled(false);
         btnUpdate.setVisible(false);

         btnInsertNew.setEnabled(false);
         btnReset.setEnabled(false);
         btnReset.setVisible(false);

         employeeWorkStagnationPanel.setEnabled(false);
      }
      
  }

  private void calculateWorkingYears()
  {
     
      try {
            /* calculate current working years for selected employee and display it in
               appropriate year
             */
            ResultSet rs = Database.getTable("Employee").getResultSet();

            if (rs != null) {

                // uzimamo prethodni radni staz.
                int workYears  = rs.getInt("EmployeeWorkingYears");
                int workMonths = rs.getInt("EmployeeWorkingMonths");
                int workDays = rs.getInt("EmployeeWorkingDays");

                // uzimamo datum kad se zaposlio na SF i tekuci datum.
                Date dt = rs.getDate("EmployeeJobDate");
                Date now = new Date();

                // get current date
                //Calendar current = Calendar.getInstance();
                //Calendar beginDate = Calendar.getInstance();
                //beginDate.setTime(dt);

                // uzimamo staz na SF, danasnji datum - datum kad je poceo na SF
                long diff = now.getTime() - dt.getTime();
                long delay = employeeWorkStagnationPanel.getTotalStagnation();
                // oduzimamo od ukupnog staza, vreme stagnacije
                diff -= delay;
                long daysDiff   = (diff / (1000L*60L*60L*24L));

                // preracunavamo razliku u danima u dane, mesece i godine.

                long yearsDiff  = daysDiff / 365;
                long monthsDiff = (daysDiff % 365) / 30;
                long restDays = (daysDiff % 365) % 30;
                /* remaining months after years division (ostatak) 
                long restMonths = ((monthsDiff/12L) % 12) + 1;

                System.out.println("Date diff " + restDays + " days");
                System.out.println("Date diff " + monthsDiff + " months");
                System.out.println("Date diff " + yearsDiff + " years");
                System.out.println("Total diff " + daysDiff + " days");
                /*
                System.out.println("Date diff " + daysDiff + " days");
                System.out.println("Date diff " + monthsDiff + " months");
                System.out.println("Date diff " + yearsDiff + " years");

                 *
                 */
                long totalWorkYears  = workYears + yearsDiff;
                int totalWorkMonths  = (int) (workMonths + monthsDiff);
                int totalWorkDays = (int) (workDays + restDays);

                if (totalWorkDays >= 30)
                {
                    totalWorkMonths += 1;

                    totalWorkDays %= 30;
                }

                // if checksum is greater than 12, increase year by 1
                if (totalWorkMonths >= 12) {
                   totalWorkYears += 1;

                   // get rest by module division
                   totalWorkMonths = (totalWorkMonths % 12);
                }


                txtCurrentWorkingYears.setText("" + totalWorkYears);
                txtCurrentWorkingMonths.setText("" + totalWorkMonths);
                txtCurrentWorkingDays.setText("" + totalWorkDays);
            }


        } catch (SQLException ex) {
            Message.showMessage("Evidencija staza", "Morate prvo uneti zapsosleng u bazu", "Zatvori");
    }

  }
  public EmployeeWorkStagnationPanel getEmployeeWorkStagnationPanel()
  {
      
      return employeeWorkStagnationPanel;
  }
  public void setEditing(boolean editing) {

    checkPrivileges();
    
    calculateWorkingYears();
    
    btnUpdate.setEnabled(editing);
    btnReset.setEnabled(editing);
    btnDelete.setEnabled(editing);
  }

  public void rowUpdated() {
    setDataModified(false);
  }

  public void rowInserted() {
    setDataModified(false);
  }

  public void clearEditor()
  {
       java.util.LinkedList<java.awt.Container> containers = new java.util.LinkedList();
      containers.add(this);
      containers.add(pnlBirthAddress1);
      containers.add(pnlBirthAddress);
      containers.add(pnlAddress);

      while(!containers.isEmpty()) {

         java.awt.Container current = containers.getFirst(); // get first element from list
         containers.removeFirst();                           // now remove it from list, it is not needed anymore

         for (java.awt.Component component: current.getComponents()) {
             if (component.getName() != null && component.getName().startsWith("flg2_")) {
              if (IntegerField.class.isInstance(component)) {
                ((IntegerField)component).setValue(0);

              } else if (DateField.class.isInstance(component)) {
                java.util.Date date;
                date = null;
                ((DateField)component).setValue(date);

              } else if (JTextField.class.isInstance(component)) {
                ((JTextField)component).setText("");
              } else if (SQLComboBox.class.isInstance(component)) {
                ((SQLComboBox)component).setValue(0);
              } else {
                System.err.println("Unknown component : " + component.getName());
              }
            }
         }

      }
      // Clear the rest of the panel.
      employeeWorkStagnationPanel.clear();
      txtCurrentWorkingDays.setText("");
      txtCurrentWorkingMonths.setText("");
      txtCurrentWorkingYears.setText("");

      // Ovo je izgleda jedini nacin da se ukloni selekcija sa RadioButon-a
      flg2_EmployeeGenderOptionGroup.remove(radioMale);
      flg2_EmployeeGenderOptionGroup.remove(radioFemale);
      radioMale.setSelected(false);
      radioFemale.setSelected(false);
      flg2_EmployeeGenderOptionGroup.add(radioMale);
      flg2_EmployeeGenderOptionGroup.add(radioFemale);

      flg2_EmployeeJobStatusButtonGroup.remove( radioFired );
      flg2_EmployeeJobStatusButtonGroup.remove( radioEmployed );
      flg2_EmployeeJobStatusButtonGroup.remove( radioRetired );
      radioFired.setSelected(false);
      radioEmployed.setSelected(false);
      radioRetired.setSelected(false);
      flg2_EmployeeJobStatusButtonGroup.add( radioFired );
      flg2_EmployeeJobStatusButtonGroup.add( radioEmployed );
      flg2_EmployeeJobStatusButtonGroup.add( radioRetired );
  }
    
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnDelete;
    private javax.swing.JButton btnInsert;
    private javax.swing.JButton btnInsertNew;
    private javax.swing.JButton btnReset;
    private javax.swing.JButton btnUpdate;
    private javax.swing.JCheckBox checkLimited;
    private org.foment.gem.beans.EmployeeWorkStagnationPanel employeeWorkStagnationPanel;
    private javax.swing.JTextField flg2_EmployeeCity;
    private javax.swing.JTextField flg2_EmployeeCityOfBirth;
    private javax.swing.JTextField flg2_EmployeeCountry;
    private javax.swing.JTextField flg2_EmployeeCountryOfBirth;
    private org.foment.joliage3.newt.DateField flg2_EmployeeDateOfBirth;
    private javax.swing.JTextField flg2_EmployeeDistrict;
    private javax.swing.JTextField flg2_EmployeeDistrictOfBirth;
    private org.foment.joliage3.newt.SQLComboBox flg2_EmployeeEducationLevel;
    private javax.swing.JTextField flg2_EmployeeFirstName;
    private javax.swing.JTextField flg2_EmployeeGender;
    private javax.swing.ButtonGroup flg2_EmployeeGenderOptionGroup;
    public javax.swing.JFormattedTextField flg2_EmployeeID;
    private javax.swing.JFormattedTextField flg2_EmployeeJMBG;
    private org.foment.joliage3.newt.DateField flg2_EmployeeJobDate;
    private org.foment.joliage3.newt.DateField flg2_EmployeeJobExpirationDate;
    private javax.swing.JTextField flg2_EmployeeJobStatus;
    private javax.swing.ButtonGroup flg2_EmployeeJobStatusButtonGroup;
    private javax.swing.JFormattedTextField flg2_EmployeeLBO;
    private javax.swing.JTextField flg2_EmployeeMidName;
    private javax.swing.JTextField flg2_EmployeeState;
    private javax.swing.JTextField flg2_EmployeeStateOfBirth;
    private javax.swing.JTextField flg2_EmployeeStreet;
    private javax.swing.JTextField flg2_EmployeeSurname;
    private org.foment.joliage3.newt.IntegerField flg2_EmployeeWorkingDays;
    private org.foment.joliage3.newt.IntegerField flg2_EmployeeWorkingMonths;
    private org.foment.joliage3.newt.IntegerField flg2_EmployeeWorkingYears;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel lblCity;
    private javax.swing.JLabel lblCityOfBirth;
    private javax.swing.JLabel lblCountry;
    private javax.swing.JLabel lblCountryOfBirth;
    private javax.swing.JLabel lblDateOfBirth;
    private javax.swing.JLabel lblDistrict;
    private javax.swing.JLabel lblDistrictOfBirth;
    private javax.swing.JLabel lblEducationLevel;
    private javax.swing.JLabel lblEmployeeJobStatus;
    private javax.swing.JLabel lblEmploymentDate;
    private javax.swing.JLabel lblFirstName;
    private javax.swing.JLabel lblGender;
    private javax.swing.JLabel lblID;
    private javax.swing.JLabel lblJMBG;
    private javax.swing.JLabel lblLBO;
    private javax.swing.JLabel lblParentName;
    private javax.swing.JLabel lblState;
    private javax.swing.JLabel lblStateOfBirth;
    private javax.swing.JLabel lblStreet;
    private javax.swing.JLabel lblSurname;
    private javax.swing.JLabel lblWorkingYears;
    private javax.swing.JPanel pnlAddress;
    private javax.swing.JPanel pnlAddresses;
    private javax.swing.JPanel pnlBirthAddress;
    private javax.swing.JPanel pnlBirthAddress1;
    private javax.swing.JPanel pnlEmployeeDataEditorButtons;
    private javax.swing.JRadioButton radioEmployed;
    private javax.swing.JRadioButton radioFemale;
    private javax.swing.JRadioButton radioFired;
    private javax.swing.JRadioButton radioMale;
    private javax.swing.JRadioButton radioRetired;
    private javax.swing.JTextField txtCurrentWorkingDays;
    private javax.swing.JTextField txtCurrentWorkingMonths;
    private javax.swing.JTextField txtCurrentWorkingYears;
    // End of variables declaration//GEN-END:variables

  /**
   * Utility field used by bound properties.
   */
  private java.beans.PropertyChangeSupport propertyChangeSupport =  new java.beans.PropertyChangeSupport(this);
  private boolean _modified;
    
}
